from rich.console import Console
from rich.bar import Bar
from rich.box import SIMPLE_HEAVY
from rich.panel import Panel
from rich.table import Table

console = Console()

# 模拟数据
data = {
    "Apple": 35,
    "Banana": 20,
    "Orange": 45,
    "Grape": 15
}

# 创建表格
table = Table(box=SIMPLE_HEAVY)
table.add_column("Fruit")
table.add_column("Sales", justify="right")
table.add_column("Bar")

# 为表格添加数据和柱状图
for fruit, value in data.items():
    bar = Bar(0, 50, value, width=20)
    table.add_row(fruit, str(value), bar)

# 将表格放入面板中展示
panel = Panel(table, title="Fruit Sales Chart", border_style="green")
console.print(panel)